package com.tjec.project.projectWorkbench.controller;

import java.util.*;

import com.tjec.common.utils.StringUtils;
import com.tjec.project.businessWorkbench.domain.BmsBusiness;
import com.tjec.project.businessWorkbench.service.IBmsBusinessService;
import com.tjec.project.projectWorkbench.domain.*;
import com.tjec.project.projectWorkbench.service.IBmsMdEngineeringKeywordIndicatorRefService;
import com.tjec.project.system.domain.SysDictData;
import com.tjec.project.system.service.ISysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectWorkbench.service.IBmsProjectIndicatorReportService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 项目指标填报 Controller
 * 
 * @author cjj
 * @date 2020-05-14
 */
@Api(value = "项目主页-项目指标" , tags = {"项目主页-项目指标接口"})
@RestController
@RequestMapping("/project/indicatorReport")
public class BmsProjectIndicatorReportController extends BaseController
{
    @Autowired
    private IBmsProjectIndicatorReportService bmsProjectIndicatorReportService;

    @Autowired
    private IBmsMdEngineeringKeywordIndicatorRefService bmsMdEngineeringKeywordIndicatorRefService;

    @Autowired
    private IBmsBusinessService bmsBusinessService;

    @Autowired
    private ISysDictDataService dictDataService;

    /**
     * 查询项目指标填报 列表
     */
    @ApiOperation("查询项目指标填报列表")
//    @PreAuthorize("@ss.hasPermi('project:indicatorReport:list')")
    @GetMapping("/list")
    public AjaxResult list(BmsProjectIndicatorReport bmsProjectIndicatorReport)
    {
        AjaxResult map = AjaxResult.success();
        String[] engineeringIdStrs = {};
        String[] performanceKeywordIdStrs = {};
        //项目指标数据
        List<BmsProjectIndicatorReport> bmsProjectIndicatorReports = bmsProjectIndicatorReportService.selectBmsProjectIndicatorReportList(bmsProjectIndicatorReport);
        BmsProjectIndicatorReport projectIndicatorReport = new BmsProjectIndicatorReport();
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReports)){
            projectIndicatorReport = bmsProjectIndicatorReports.get(0);
            engineeringIdStrs = StringUtils.isNotBlank(projectIndicatorReport.getEngineeringId())?projectIndicatorReport.getEngineeringId().split(";",-1):null;
            performanceKeywordIdStrs = StringUtils.isNotBlank(projectIndicatorReport.getPerformanceKeywordId())?projectIndicatorReport.getPerformanceKeywordId().split(";",-1):null;
            if(engineeringIdStrs!=null&&engineeringIdStrs.length>0){
                projectIndicatorReport.setEngineeringIds(new HashSet<>(Arrays.asList(engineeringIdStrs)));
            }
            if(performanceKeywordIdStrs!=null&&performanceKeywordIdStrs.length>0){
                projectIndicatorReport.setPerformanceKeywordIds(new HashSet<>(Arrays.asList(performanceKeywordIdStrs)));
            }
        }
        map.put("guid",null==projectIndicatorReport?"":projectIndicatorReport.getGuid());
        map.put("projectId",bmsProjectIndicatorReport.getProjectId());
        //必填指标项目
        map.put("requiredIndicators",getRequiredIndicators());
        BmsMdEngineeringKeywordIndicatorRef engineeringRef = new BmsMdEngineeringKeywordIndicatorRef();
        //工程类别
        BmsMdEngineeringCategory engineeringCategory = new BmsMdEngineeringCategory();
        engineeringCategory.setType(1);
        //第一层工程类别
        List<BmsMdEngineeringCategory> bmsMdEngineeringCategoryList = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringCategoryList(engineeringCategory);
        
        for (BmsMdEngineeringCategory categoryFir : bmsMdEngineeringCategoryList) {
            //第一层工程类别对应指标项
            engineeringRef.setRelatedObject(0);
            engineeringRef.setEngineeringId(categoryFir.getEngineeringId());
//            List<BmsMdEngineeringKeywordIndicatorRef> bmsMdEngineeringKeywordIndicatorRefs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(engineeringRef);
//            categoryFir.setIndicators(getIndicatorData(engineeringRef, indicatorIdStrs, indicators));
            //第二层工程类别
            categoryFir.setSelected(StringUtils.existArray(engineeringIdStrs, categoryFir.getEngineeringId()));
            engineeringCategory.setType(2);
            engineeringCategory.setParentId(categoryFir.getEngineeringId());
            List<BmsMdEngineeringCategory> categorySecs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringCategoryList(engineeringCategory);
            for (BmsMdEngineeringCategory categorySec : categorySecs) {
            	
                //第二层工程类别对应指标项
                engineeringRef.setRelatedObject(0);
                engineeringRef.setEngineeringId(categorySec.getEngineeringId());
//                List<BmsMdEngineeringKeywordIndicatorRef> indicatorRefSecs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(engineeringRef);
//                categorySec.setIndicators(getIndicatorData(engineeringRef, indicatorIdStrs, indicators));
                categorySec.setSelected(StringUtils.existArray(engineeringIdStrs, categorySec.getEngineeringId()));
                engineeringCategory.setType(3);
                engineeringCategory.setParentId(categorySec.getEngineeringId());
                //第三层工程类别
                List<BmsMdEngineeringCategory> categoryThis = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringCategoryList(engineeringCategory);
                for (BmsMdEngineeringCategory categoryThi : categoryThis) {
                	
                    //第三层工程类别对应指标项
                    engineeringRef.setRelatedObject(0);
                    engineeringRef.setEngineeringId(categoryThi.getEngineeringId());
//                    List<BmsMdEngineeringKeywordIndicatorRef> indicatorRefThi = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(engineeringRef);
//                    categoryThi.setIndicators(getIndicatorData(engineeringRef, indicatorIdStrs, indicators));
                    categoryThi.setSelected(StringUtils.existArray(engineeringIdStrs, categoryThi.getEngineeringId()));
                }
                categorySec.setChildren(categoryThis);
            }
            categoryFir.setChildren(categorySecs);
        }
        StringBuffer engineerings = new StringBuffer();
        Set<String> detailEngineerings = new HashSet<String>();
        if(bmsMdEngineeringCategoryList!=null && bmsMdEngineeringCategoryList.size()>0) {
        	for (BmsMdEngineeringCategory bmsMdEngineeringCategory : bmsMdEngineeringCategoryList) {
        		if(bmsMdEngineeringCategory.getSelected()) {
            		if(engineerings.length()>0) {
            			engineerings.append("；"+bmsMdEngineeringCategory.getEngineeringName());
            		}else {
            			engineerings.append(bmsMdEngineeringCategory.getEngineeringName());
            		}
            	}
        		List<BmsMdEngineeringCategory> childrens = bmsMdEngineeringCategory.getChildren();
        		if(childrens!=null && childrens.size()>0) {
        			for (BmsMdEngineeringCategory children : childrens) {
						if(children.getSelected()) {
							detailEngineerings.add(children.getEngineeringName());
						}
						List<BmsMdEngineeringCategory> thirds = children.getChildren();
						if(thirds!=null && thirds.size()>0) {
							for (BmsMdEngineeringCategory string : thirds) {
								if(string.getSelected()) {
									detailEngineerings.add(string.getEngineeringName());
								}
							}
						}
					}
        		}
			}
        }
        map.put("bmsMdEngineeringCategorys",bmsMdEngineeringCategoryList);
        map.put("engineerings", engineerings);
        map.put("engineeringsChildren", detailEngineerings!=null && detailEngineerings.size()>0?StringUtils.join(detailEngineerings,"；"):"");
        //关键字
        BmsMdEngineeringKeywordIndicatorRef keywordRef = new BmsMdEngineeringKeywordIndicatorRef();
        List<BmsMdPerformanceKeyword> bmsMdPerformanceKeywordList = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdPerformanceKeywordList(new BmsMdPerformanceKeyword());
        for (BmsMdPerformanceKeyword bmsMdPerformanceKeyword : bmsMdPerformanceKeywordList) {
            bmsMdPerformanceKeyword.setSelected(StringUtils.existArray(performanceKeywordIdStrs, bmsMdPerformanceKeyword.getPerformanceKeywordId()));
            //关键字对应指标项
            keywordRef.setRelatedObject(1);
            keywordRef.setPerformanceKeywordId(bmsMdPerformanceKeyword.getPerformanceKeywordId());
//            List<BmsMdEngineeringKeywordIndicatorRef> bmsMdEngineeringKeywordIndicatorRefs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(keywordRef);
//            bmsMdPerformanceKeyword.setIndicators(getIndicatorData(keywordRef, indicatorIdStrs, indicators));
        }
        map.put("bmsMdPerformanceKeywords",bmsMdPerformanceKeywordList);
        StringBuffer keyWords = new StringBuffer();
        if(bmsMdPerformanceKeywordList!=null && bmsMdPerformanceKeywordList.size()>0) {
        	for (BmsMdPerformanceKeyword bmsMdPerformanceKeyword : bmsMdPerformanceKeywordList) {
            		if(bmsMdPerformanceKeyword.isSelected()) {
                		if(keyWords.length()>0) {
                			keyWords.append("；"+bmsMdPerformanceKeyword.getPerformanceKeywordName());
                		}else {
                			keyWords.append(bmsMdPerformanceKeyword.getPerformanceKeywordName());
                		}
                	}
            }
        }
        map.put("keyWords",keyWords);
        return map;
    }

    /**
     * 查询项目指标填报 列表
     */
    @ApiOperation("获取指标填表指标项")
//    @PreAuthorize("@ss.hasPermi('project:indicatorReport:getIndicators')")
    @PostMapping("/getIndicators")
    public AjaxResult getIndicators(@RequestBody BmsProjectIndicatorReport bmsProjectIndicatorReport)
    {
        List<BmsMdEngineeringKeywordIndicatorRef> list = new ArrayList<>();
        //项目指标数据
        String[] indicatorIdStrs = {};
        String[] indicatorValueStrs = {};
        Set<Map<String, Object>> indicators = new HashSet<>();
        List<BmsProjectIndicatorReport> bmsProjectIndicatorReports = bmsProjectIndicatorReportService.selectBmsProjectIndicatorReportList(bmsProjectIndicatorReport);
        BmsProjectIndicatorReport projectIndicatorReport = new BmsProjectIndicatorReport();
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReports)){
            projectIndicatorReport = bmsProjectIndicatorReports.get(0);
            //获取项目指标id和指标值，合成Set集合
            if(StringUtils.isNotBlank(projectIndicatorReport.getIndicatorId())) {
            	indicatorIdStrs = StringUtils.split(projectIndicatorReport.getIndicatorId(),";");
            }
            if(StringUtils.isNotBlank(projectIndicatorReport.getIndicatorValue())) {
            	indicatorValueStrs = StringUtils.split(projectIndicatorReport.getIndicatorValue(),";");
            }
            
            if(indicatorIdStrs!=null&&indicatorIdStrs.length>0 && indicatorValueStrs!=null && indicatorValueStrs.length>0){
                for (int i = 0; i < indicatorIdStrs.length; i++) {
                    Map<String, Object> indicatorsMap = new HashMap<>();
                    indicatorsMap.put(indicatorIdStrs[i], indicatorValueStrs[i]);
                    indicators.add(indicatorsMap);
                }
            }
        }
        
        list = bmsMdEngineeringKeywordIndicatorRefService.selectDefaultIndicatorRefList();
        if(!CollectionUtils.isEmpty(bmsProjectIndicatorReport.getEngineeringIds())){
            list = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefListByEngineeringIds(bmsProjectIndicatorReport.getEngineeringIds());
        }
        if(!CollectionUtils.isEmpty(bmsProjectIndicatorReport.getPerformanceKeywordIds())){
            list.addAll(bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefListByPerformanceKeywordIds(bmsProjectIndicatorReport.getPerformanceKeywordIds()));
        }
        for (BmsMdEngineeringKeywordIndicatorRef indicatorRef : list) {
            if(indicatorRef.getFieldUnit()==2){
                indicatorRef.setDictDatas(dictDataService.selectDictDataByDictName(indicatorRef.getIndicatorName()));
            }
            if(StringUtils.existArray(indicatorIdStrs, indicatorRef.getIndicatorId())){
                indicatorRef.setIndicatorValue(getSetValue(indicators ,indicatorRef.getIndicatorId()));
                indicatorRef.setSelected(true);
            }else{
                indicatorRef.setSelected(false);
            }
        }
        return AjaxResult.success(list);
    }

    /**
     * 必填指标项目
     * @return
     */
    public Set<String> getRequiredIndicators(){
        Set<String> requiredIndicators = new HashSet<>();
        BmsMdEngineeringKeywordIndicatorRef requiredIndicatorsRef = new BmsMdEngineeringKeywordIndicatorRef();
        requiredIndicatorsRef.setIsRequired(true);
        List<BmsMdEngineeringKeywordIndicatorRef> list = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(requiredIndicatorsRef);
        for (BmsMdEngineeringKeywordIndicatorRef bmsMdEngineeringKeywordIndicatorRef : list) {
            if(StringUtils.isNotBlank(bmsMdEngineeringKeywordIndicatorRef.getIndicatorId())){
                requiredIndicators.add(bmsMdEngineeringKeywordIndicatorRef.getIndicatorId());
            }
        }
        return requiredIndicators;
    }

    public List<BmsMdEngineeringKeywordIndicatorRef> getIndicatorData(BmsMdEngineeringKeywordIndicatorRef keywordRef,String[] indicatorIdStrs, Set<Map<String, Object>> indicators){
        List<BmsMdEngineeringKeywordIndicatorRef> bmsMdEngineeringKeywordIndicatorRefs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(keywordRef);
        for (BmsMdEngineeringKeywordIndicatorRef indicatorRef : bmsMdEngineeringKeywordIndicatorRefs) {
            if(indicatorRef.getFieldUnit()==2){
                List<SysDictData> list = dictDataService.selectDictDataByDictName(indicatorRef.getIndicatorName());
                indicatorRef.setDictDatas(list);
            }
            if(StringUtils.existArray(indicatorIdStrs, indicatorRef.getIndicatorId())){
                indicatorRef.setIndicatorValue(getSetValue(indicators ,indicatorRef.getIndicatorId()));
                indicatorRef.setSelected(true);
            }else{
                indicatorRef.setSelected(false);
            }
        }
        return bmsMdEngineeringKeywordIndicatorRefs;
    }

    public String getSetValue(Set<Map<String, Object>> indicators, String indicatorId){
        String indicatorValue = "";
        for (Map<String, Object> indicator : indicators) {
            if(null==indicator.get(indicatorId)){
                continue;
            }else{
                indicatorValue = indicator.get(indicatorId).toString();
                break;
            }
        }
        return indicatorValue;
    }

    /**
     * 原指标填报
     */
    /*public AjaxResult oldList(BmsProjectIndicatorReport bmsProjectIndicatorReport){
        if(StringUtils.isBlank(bmsProjectIndicatorReport.getProjectId())){
            return AjaxResult.error("项目ID不能为空");
        }
        Map<String, Object> map = new HashMap<>();
        //获取该项目所有业务名称并去重
        BmsBusiness bmsBusiness = new BmsBusiness();
        bmsBusiness.setProjectId(bmsProjectIndicatorReport.getProjectId());
        List<BmsBusiness> bmsBusinesss = bmsBusinessService.selectBmsBusinessList(bmsBusiness);
        Set<String> businessCategory = new HashSet<>();
        for (BmsBusiness business : bmsBusinesss) {
            businessCategory.add(business.getMenuName());
        }
        map.put("businessCategory",businessCategory);
        //项目指标数据
        List<BmsProjectIndicatorReport> bmsProjectIndicatorReports = bmsProjectIndicatorReportService.selectBmsProjectIndicatorReportList(bmsProjectIndicatorReport);
        String[] engineeringIdStrs = {};
        String[] performanceKeywordIdStrs = {};
        String[] indicatorIdStrs = {};
        String[] indicatorValueStrs = {};
        Set<Map<String, Object>> indicators = new HashSet<>();
        BmsProjectIndicatorReport projectIndicatorReport = new BmsProjectIndicatorReport();
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReports)){
            projectIndicatorReport = bmsProjectIndicatorReports.get(0);
            engineeringIdStrs = StringUtils.isNotBlank(projectIndicatorReport.getEngineeringId())?projectIndicatorReport.getEngineeringId().split(";"):null;
            performanceKeywordIdStrs = StringUtils.isNotBlank(projectIndicatorReport.getPerformanceKeywordId())?projectIndicatorReport.getPerformanceKeywordId().split(";"):null;
            projectIndicatorReport.setEngineeringIds(new HashSet<>(Arrays.asList(engineeringIdStrs)));
            projectIndicatorReport.setPerformanceKeywordIds(new HashSet<>(Arrays.asList(performanceKeywordIdStrs)));
            //获取项目指标id和指标值，合成Set集合
            indicatorIdStrs = StringUtils.isNotBlank(projectIndicatorReport.getIndicatorId())?projectIndicatorReport.getIndicatorId().split(";"):null;
            indicatorValueStrs = StringUtils.isNotBlank(projectIndicatorReport.getIndicatorValue())?projectIndicatorReport.getIndicatorValue().split(";"):null;
            for (int i = 0; i < indicatorIdStrs.length; i++) {
                Map<String, Object> indicatorsMap = new HashMap<>();
                indicatorsMap.put(indicatorIdStrs[i], indicatorValueStrs[i]);
                indicators.add(indicatorsMap);
            }
        }
//        map.put("selectedData",projectIndicatorReport);
        map.put("guid",null==projectIndicatorReport?"":projectIndicatorReport.getGuid());
        map.put("projectId",bmsProjectIndicatorReport.getProjectId());
        //工程类别
        List<BmsMdEngineeringCategory> bmsMdEngineeringCategoryList = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringCategoryList(new BmsMdEngineeringCategory());
        for (BmsMdEngineeringCategory bmsMdEngineeringCategory : bmsMdEngineeringCategoryList) {
            bmsMdEngineeringCategory.setSelected(StringUtils.existArray(engineeringIdStrs, bmsMdEngineeringCategory.getEngineeringId()));
        }
        map.put("bmsMdEngineeringCategorys",bmsMdEngineeringCategoryList);
        //关键字
        List<BmsMdPerformanceKeyword> bmsMdPerformanceKeywordList = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdPerformanceKeywordList(new BmsMdPerformanceKeyword());
        for (BmsMdPerformanceKeyword bmsMdPerformanceKeyword : bmsMdPerformanceKeywordList) {
            bmsMdPerformanceKeyword.setSelected(StringUtils.existArray(performanceKeywordIdStrs, bmsMdPerformanceKeyword.getPerformanceKeywordId()));
            BmsMdEngineeringKeywordIndicatorRef bmsMdEngineeringKeywordIndicatorRef = new BmsMdEngineeringKeywordIndicatorRef();
            bmsMdEngineeringKeywordIndicatorRef.setPerformanceKeywordId(bmsMdPerformanceKeyword.getPerformanceKeywordId());
            List<BmsMdEngineeringKeywordIndicatorRef> bmsMdEngineeringKeywordIndicatorRefs = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdEngineeringKeywordIndicatorRefList(bmsMdEngineeringKeywordIndicatorRef);
            for (BmsMdEngineeringKeywordIndicatorRef engineeringKeywordIndicatorRef : bmsMdEngineeringKeywordIndicatorRefs) {
                if(StringUtils.existArray(indicatorIdStrs, engineeringKeywordIndicatorRef.getIndicatorId())){
                    engineeringKeywordIndicatorRef.setIndicatorValue(getSetValue(indicators ,engineeringKeywordIndicatorRef.getIndicatorId()));
                    engineeringKeywordIndicatorRef.setSelected(true);
                }else{
                    engineeringKeywordIndicatorRef.setSelected(false);
                }
            }
            bmsMdPerformanceKeyword.setChildren(bmsMdEngineeringKeywordIndicatorRefs);
        }
        map.put("bmsMdPerformanceKeywords",bmsMdPerformanceKeywordList);
        //通用指标
        BmsMdProjectIndicator bmsMdProjectIndicator = new BmsMdProjectIndicator();
        bmsMdProjectIndicator.setDefaultFlag("1");
        List<BmsMdProjectIndicator> bmsMdProjectIndicators = bmsMdEngineeringKeywordIndicatorRefService.selectBmsMdProjectIndicatorList(bmsMdProjectIndicator);
        for (BmsMdProjectIndicator mdProjectIndicator : bmsMdProjectIndicators) {
            if(StringUtils.existArray(indicatorIdStrs, mdProjectIndicator.getIndicatorId())){
                mdProjectIndicator.setIndicatorValue(getSetValue(indicators ,mdProjectIndicator.getIndicatorId()));
            }
        }
        map.put("defaultBmsMdProjectIndicators",bmsMdProjectIndicators);
        return AjaxResult.success(map);
    }*/

    /**
     * 保存项目指标填报
     */
    @ApiOperation("保存项目指标填报")
    @Log(title = "项目指标填报 ", businessType = BusinessType.INSERT)
//    @PreAuthorize("@ss.hasPermi('project:indicatorReport:add')")
    @PostMapping
    public AjaxResult add(@RequestBody BmsProjectIndicatorReport bmsProjectIndicatorReport) {
        int res = 0;
        //工程类别
        String engineeringIds = "";
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReport.getEngineeringIds())){
            for (String engineeringId : bmsProjectIndicatorReport.getEngineeringIds()) {
                engineeringIds += engineeringId+";";
            }
        }
        bmsProjectIndicatorReport.setEngineeringId(engineeringIds);
        //关键字
        String performanceKeywordIds = "";
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReport.getPerformanceKeywordIds())){
            for (String performanceKeywordId : bmsProjectIndicatorReport.getPerformanceKeywordIds()) {
                performanceKeywordIds += performanceKeywordId+";";
            }
        }
        bmsProjectIndicatorReport.setPerformanceKeywordId(performanceKeywordIds);
        //项目指标
        String indicatorIds = "";
        String indicatorValues = "";
        if(CollectionUtils.isNotEmpty(bmsProjectIndicatorReport.getIndicators())){
            for (Map<String, Object> indicators : bmsProjectIndicatorReport.getIndicators()) {
                for (Map.Entry<String, Object> indicator : indicators.entrySet()) {
                    indicatorIds += indicator.getKey()+";";
                    indicatorValues += indicator.getValue()+";";
                }
            }
            bmsProjectIndicatorReport.setIndicatorId(indicatorIds);
            bmsProjectIndicatorReport.setIndicatorValue(indicatorValues);
        }
        bmsProjectIndicatorReport.setIndicatorId(indicatorIds);
        bmsProjectIndicatorReport.setIndicatorValue(indicatorValues);
        //主键为空则新增不为空则为修改
        if (StringUtils.isNotBlank(bmsProjectIndicatorReport.getGuid())){
            res = bmsProjectIndicatorReportService.updateBmsProjectIndicatorReport(bmsProjectIndicatorReport);
        }else{
            res = bmsProjectIndicatorReportService.insertBmsProjectIndicatorReport(bmsProjectIndicatorReport);
        }
        return toAjax(res);
    }
    
}
